package LeetCode;

import java.util.ArrayList;
import java.util.List;

public class LC_728 {
    public static List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> res = new ArrayList<>();
        for (int i = left; i <= right; i++) {
            if (i<10){
                res.add(i);
            }else{
                int num = i, high =0,low =0;
                boolean flag = true;
                while(num>0){
                    high = num/10;
                    low = num%10;
                    if(low==0 || i%low!=0){
                        flag=false;
                        break;
                    }
                    num = high;
                }
                if (flag && i!=10){
                    res.add(i);
                }

            }

        }
        return res;

    }

    public static void main(String[] args) {
        System.out.println(selfDividingNumbers(2,22));
    }
}
